/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author wesleycl
 */
@Entity
@Table(name = "maintenance_project")
//@NamedQueries({@NamedQuery(name = "MaintenanceProject.findAll", query = "SELECT m FROM MaintenanceProject m")})
public class MaintenanceProject implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "project_number")
    private String projectNumber;
    @JoinColumn(name = "customer", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Customer customer;

    @JoinColumn(name = "vehicle", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Vehicle vehicle;

    @JoinColumn(name = "warrenty_contract", referencedColumnName = "id")
    @ManyToOne
    private WarrentyContract warrentyContract;

    @ManyToMany
    @JoinTable(name="maintenanceproject_marketingevent",
        joinColumns=
            @JoinColumn(name="maintanance_project",referencedColumnName="id"),
        inverseJoinColumns=
            @JoinColumn(name="marketing_event",referencedColumnName="id")
        )
    private List <MarketingEvent> marketingEventCollection ;


    public MaintenanceProject() {
    }

    public MaintenanceProject(Integer id) {
        this.id = id;
    }

    public MaintenanceProject(Integer id, String projectNumber) {
        this.id = id;
        this.projectNumber = projectNumber;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getProjectNumber() {
        return projectNumber;
    }

    public void setProjectNumber(String projectNumber) {
        this.projectNumber = projectNumber;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MaintenanceProject)) {
            return false;
        }
        MaintenanceProject other = (MaintenanceProject) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.MaintenanceProject[id=" + id + "]";
    }

    /**
     * @return the vehicle
     */
    public Vehicle getVehicle() {
        return vehicle;
    }

    /**
     * @param vehicle the vehicle to set
     */
    public void setVehicle(Vehicle vehicle) {
        this.vehicle = vehicle;
    }

    /**
     * @return the warrentyContract
     */
    public WarrentyContract getWarrentyContract() {
        return warrentyContract;
    }

    /**
     * @param warrentyContract the warrentyContract to set
     */
    public void setWarrentyContract(WarrentyContract warrentyContract) {
        this.warrentyContract = warrentyContract;
    }

    /**
     * @return the marketingEventCollection
     */
    public List<MarketingEvent> getMarketingEventCollection() {
        return marketingEventCollection;
    }

    /**
     * @param marketingEventCollection the marketingEventCollection to set
     */
    public void setMarketingEventCollection(List<MarketingEvent> marketingEventCollection) {
        this.marketingEventCollection = marketingEventCollection;
    }

}
